package com.peanut.baby.mvp.calendar;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

import com.peanut.baby.InitManager;
import com.peanut.baby.R;
import com.peanut.baby.util.ImageUtil;
import com.peanut.devlibrary.util.SysUtil;

/**
 * Created by anonymouslystudio on 2017/9/6.
 */

public class CalendarCache {

    private static Bitmap pailuanBitmap;
    private static Drawable yiyunDrawable;
    private static Drawable yuejingDrawable;

    private static Bitmap hasRecordBitmap;
    private static Bitmap menseStartBitmap;
    private static Bitmap menseEndBitmap;

    private static int      yiyunColor = -1;
    private static int      yuejingColor = -1;

    public static Bitmap getPailuanBitmap(){
        if(pailuanBitmap == null){
            Drawable pailuanDrawable = InitManager.getInstance().getCtx().getResources().getDrawable(R.drawable.test_calendar_drawable);
            Bitmap bit = ((BitmapDrawable) pailuanDrawable).getBitmap();
            pailuanBitmap = ImageUtil.resizeImage(bit, SysUtil.dip2px(10),SysUtil.dip2px(10));
        }
        return pailuanBitmap;
    }

    public static Bitmap getHasRecordBitmap(){
        if(hasRecordBitmap == null){
            Drawable pailuanDrawable = InitManager.getInstance().getCtx().getResources().getDrawable(R.drawable.icon_calendar_has_record);
            Bitmap bit = ((BitmapDrawable) pailuanDrawable).getBitmap();
            hasRecordBitmap = ImageUtil.resizeImage(bit, SysUtil.dip2px(10),SysUtil.dip2px(10));
        }
        return hasRecordBitmap;
    }

    public static Bitmap getMenseStartBitmap(){
        if(menseStartBitmap == null){
            Drawable pailuanDrawable = InitManager.getInstance().getCtx().getResources().getDrawable(R.drawable.icon_calendar_mense_start);
            Bitmap bit = ((BitmapDrawable) pailuanDrawable).getBitmap();
            menseStartBitmap = ImageUtil.resizeImage(bit, SysUtil.dip2px(10),SysUtil.dip2px(10));
        }
        return menseStartBitmap;
    }

    public static Bitmap getMenseEndBitmap(){
        if(menseEndBitmap == null){
            Drawable pailuanDrawable = InitManager.getInstance().getCtx().getResources().getDrawable(R.drawable.icon_calendar_mense_end);
            Bitmap bit = ((BitmapDrawable) pailuanDrawable).getBitmap();
            menseEndBitmap = ImageUtil.resizeImage(bit, SysUtil.dip2px(10),SysUtil.dip2px(10));
        }
        return menseEndBitmap;
    }

    public static Drawable getYiyunDrawable(){
        if(yiyunDrawable == null){
            yiyunDrawable = InitManager.getInstance()
                    .getCtx()
                    .getResources()
                    .getDrawable(R.drawable.selector_calendar_pregnant_period);
        }
        return yiyunDrawable;
    }

    public static Drawable getYuejingDrawable(){
        if(yuejingDrawable == null){
            yuejingDrawable = InitManager.getInstance()
                    .getCtx()
                    .getResources()
                    .getDrawable(R.drawable.selector_calendar_yuejing_period);
        }
        return yuejingDrawable;
    }


    public static int getYuejingColor(){
        if(yuejingColor == -1){
            yuejingColor = InitManager.getInstance()
                    .getCtx()
                    .getResources()
                    .getColor(R.color.colorPrimaryDark);
        }
        return yuejingColor;
    }

    public static int getYiyunColor(){
        if(yiyunColor == -1){
            yiyunColor = InitManager.getInstance()
                    .getCtx()
                    .getResources()
                    .getColor(R.color.ask_type_qita_text);
        }
        return yiyunColor;
    }


}
